import {request} from './request.js'
import store from '../store';
export const getUser = (info) => {
	request({
		url: 'user/third',
		method: 'POST',
		data: {
			loginData: info,
			platform: "mp_weixin"
		}
	}).then(res => {
		if (res.data.data.binding == 0) {
			uni.navigateTo({
				url: '/pages/user/perfect?thirdId=' + res.data.data.third_id
			})
		} else {
			if(!res.data.data.userinfo.mobile){
				// 没有绑定手机号
				uni.setStorageSync('tempUserInfo',res.data.data.userinfo);
				uni.setStorageSync('tempStatistics',res.data.data.statistics);
				uni.navigateTo({
					url: '/pages/user/bindPhone?backPageNum='+1
				})
			}else{
				store.commit("setData", res.data.data.userinfo);
				store.commit("setRecordData",res.data.data.statistics);
				store.commit("setIsLogin", true);
				store.dispatch('getCarList')
				store.dispatch('getCollection')
				store.dispatch('getBrowse')
				uni.navigateBack({})
			}
			
		}
	})
}
